/*
 * Copyright© 2003-2019 浙江汇信科技有限公司, All Rights Reserved.
 */
package com.icinfo.cloud.provider.punish.controller;

import com.icinfo.cloud.provider.common.constant.Constant;
import com.icinfo.cloud.provider.common.page.PageResponse;
import com.icinfo.cloud.provider.punish.dto.CaseMainTaskQueryDto;
import com.icinfo.cloud.provider.punish.dto.SlightIllegalUnPunishPageRequest;
import com.icinfo.cloud.provider.punish.service.ICaseMainInfoService;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseDetailInfoQueryDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.dto.CaseLinkOperateBusiInfoQueryDto;
import com.icinfo.cloud.provider.punish.ucase.casemain.vo.*;
import com.icinfo.cloud.provider.punish.vo.CaseMainTaskVo;
import com.icinfo.cloud.provider.punish.vo.CaseOfSlightIllegalVo;
import com.icinfo.cloud.provider.punish.vo.CaseStageAppAdditionOperateDocumentVo;
import com.icinfo.framework.common.web.Result;
import com.icinfo.framework.core.web.BaseController;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 【掌上办案V1.1】  描述: 案件操作前端控制器
 *
 * @author framework generator
 * @date 2022年06月15日
 */
@RestController
@RefreshScope
@RequestMapping("/app/case/main")
@Slf4j
public class CaseMainInfoController extends BaseController {

    @Resource
    private ICaseMainInfoService caseMainInfoService;

    /*@Resource
    private PunishCaseFeignClient punishCaseFeignClient;*/

    /**
     * 获取任务列表(代办及办结案件)
     *
     * @return {@link Result< PageResponse< CaseMainTaskVo>>}
     * @author: zhengqiang
     * @date: 2022/6/16
     * @param: queryDto
     **/
    @RequestMapping("/getCaseMainTaskList")
    public Result<PageResponse<CaseMainTaskVo>> getCaseMainTaskList(@RequestBody @Validated CaseMainTaskQueryDto queryDto) {
        List<CaseMainTaskVo> caseMainTaskList = caseMainInfoService.getCaseMainTaskList(queryDto);
        return Result.success(Constant.STRING_GET_SUCCESS, new PageResponse<>(caseMainTaskList));
    }


    /**
     * 【V1.9.4】描述： 查询简易处罚案件详情
     *
     * @return {@link Result<  CaseDetailSimpleInfoVo >}
     * @author: zhengqiang
     * @date: 2022/6/15
     * @param: queryDto
     **/
    @PostMapping("/getCaseDetailSimpleInfo")
    public Result<CaseDetailSimpleInfoVo> getCaseDetailSimpleInfo(@RequestBody @Validated CaseDetailInfoQueryDto queryDto) {
        return caseMainInfoService.getCaseDetailSimpleInfo(queryDto);
        //return punishCaseFeignClient.getCaseDetailSimpleInfo(queryDto);
    }

    /**
     * 【1.7.2】根据案件阶段获取对应文书
     *
     * @param caseId 用例id
     * @return {@link Result<List<CaseDocumentCatalogChainInfoVo>> }
     * @author shishengyao
     * @date 2022/11/22
     */

    @GetMapping("/getCaseStageDocumentInfoList")
    @ApiOperation(value = "【V1.0.0】描述：案件详情左边案件目录查询", httpMethod = "Get")
    public Result<List<CaseDocumentCatalogChainInfoVo>> getCaseStageDocumentInfoList(@RequestParam String caseId) {
        return caseMainInfoService.getCaseStageDocumentInfoList(caseId);
    }

    /**
     * 【V1.9.4】描述： 查询当前办案人员轻微违法不予处罚记录
     *
     * @return {@link Result< PageResponse< CaseOfSlightIllegalVo>>}
     * @author: zhengqiang
     * @date: 2022/12/11
     * @param: pageRequest
     **/
    @PostMapping("/getSlightIllegalUnPunishCaseList")
    public Result<PageResponse<CaseOfSlightIllegalVo>> getSlightIllegalUnPunishCaseList(@RequestBody @Validated SlightIllegalUnPunishPageRequest pageRequest) {
        List<CaseOfSlightIllegalVo> slightIllegalCaseList = caseMainInfoService.getSlightIllegalUnPunishCaseList(pageRequest);
        return Result.success(Constant.STRING_GET_SUCCESS, new PageResponse<>(slightIllegalCaseList));
    }

    /**
     * 【V1.4.1】描述：返回案件主流程当前环节的操作按钮-详情页底部，包括流程操作、下一步、更多操作
     *
     * @param caseId
     * @return {@link Result< CaseRecallLinkVo>}
     * @author tianrunjia
     * @date 2022/8/24
     */
    @GetMapping("/getCaseCurrentLinkOperate")
    public Result<CaseCurrentLinkOperateVo> getCaseCurrentLinkOperate(@RequestParam(value = "caseId") String caseId) {
        return caseMainInfoService.doGetCaseCurrentLinkOperate(caseId);
    }

    /**
     * 【V1.10.0】描述：获取文书按阶段的列表及每个文书的状态及对应的操作
     *
     * @param caseId
     * @author tianrunjia
     * @date 2022/12/11
     */
    @GetMapping("/getCaseStageDocumentDetailInfos")
    @ApiOperation(value = "【V1.10.0】描述：获取文书按阶段的列表及每个文书的状态及对应的操作", httpMethod = "Get")
    public Result<List<CaseStageDocumentRelationInfoVo>> getCaseStageDocumentDetailInfos(@RequestParam(value = "caseId") String caseId) {
        return caseMainInfoService.getCaseStageDocumentDetailInfos(caseId);
    }


    /**
     * 【V1.10.0】描述：案件按环节操作所需信息获取
     *
     * @param queryDto
     * @author tianrunjia
     * @date 2022/12/11
     */
    @PostMapping("/getCaseLinkOperateBusiInfo")
    @ApiOperation(value = "【V1.10.0】描述：案件按环节操作所需信息获取", httpMethod = "POST")
    public Result<CaseDetailOperateDocInfoVo> getCaseLinkOperateBusiInfo(@RequestBody @Validated CaseLinkOperateBusiInfoQueryDto queryDto) {
        return caseMainInfoService.getCaseLinkOperateBusiInfo(queryDto);
    }

    /**
     * 【V1.11.1】描述：获取当前阶段案件可操作文书信息
     *
     * @param caseId 用例id
     * @return {@link Result<CaseStageOperateDocumentVo> }
     * @author shishengyao
     * @date 2023/03/09
     */
    @GetMapping("/getCaseStageOperateDocument")
    @ApiOperation(value = "【V1.4.1】描述：获取当前阶段案件可操作文书信息", httpMethod = "GET")
    public Result<CaseStageOperateDocumentVo> getCaseStageOperateDocument(@RequestParam String caseId, @RequestParam String isMobile) {
        Result<CaseStageOperateDocumentVo> result = caseMainInfoService.getCaseStageOperateDocument(caseId, isMobile);
        return result;
    }


    /**
     * 【V1.8】描述：移动端获取当前阶段附加的可操作文书信息
     *
     * @param caseId 案件id
     * @return 移动端当前阶段可操作的附加文书（非工作流中的文书）
     * @auth Junfeng.Chen
     * @date 2023/12/15
     */
    @GetMapping("/getCaseStageAppAdditionOperateDocument")
    @ApiOperation(value = "", httpMethod = "GET")
    public Result<List<CaseStageAppAdditionOperateDocumentVo>> getCaseStageAppAdditionOperateDocument(@RequestParam String caseId) {
        return Result.success(caseMainInfoService.getCaseStageAppAdditionOperateDocument(caseId));
    }


    /**
     * 查询证据数量
     *
     * @param caseId
     * @return
     */
    @GetMapping("/getEvideceCountForCase")
    public Result<Integer> getEvideceCountForCase(@RequestParam String caseId) {
        return caseMainInfoService.getEvideceCountForCase(caseId);
    }

    /**
     * 查询证据列表
     *
     * @param caseId
     * @return
     */
    @GetMapping("/getEvideceInfo")
    public Result getEvideceInfo(@RequestParam String caseId) {
        return caseMainInfoService.getEvideceInfo(caseId);
    }
}
